package com.ruoyi.system.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.system.domain.MystockName;
import com.ruoyi.system.service.IMystockNameService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 公司名称Controller
 * 
 * @author ruoyi
 * @date 2023-03-04
 */
@RestController
@RequestMapping("/system/name")
public class MystockNameController extends BaseController
{
    @Autowired
    private IMystockNameService mystockNameService;

    /**
     * 查询公司名称列表
     */
    @PreAuthorize("@ss.hasPermi('system:name:list')")
    @GetMapping("/list")
    public TableDataInfo list(MystockName mystockName)
    {
        startPage();
        List<MystockName> list = mystockNameService.selectMystockNameList(mystockName);
        return getDataTable(list);
    }

    /**
     * 导出公司名称列表
     */
    @PreAuthorize("@ss.hasPermi('system:name:export')")
    @Log(title = "公司名称", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, MystockName mystockName)
    {
        List<MystockName> list = mystockNameService.selectMystockNameList(mystockName);
        ExcelUtil<MystockName> util = new ExcelUtil<MystockName>(MystockName.class);
        util.exportExcel(response, list, "公司名称数据");
    }

    /**
     * 获取公司名称详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:name:query')")
    @GetMapping(value = "/{tsCode}")
    public AjaxResult getInfo(@PathVariable("tsCode") String tsCode)
    {
        return success(mystockNameService.selectMystockNameByTsCode(tsCode));
    }

    /**
     * 新增公司名称
     */
    @PreAuthorize("@ss.hasPermi('system:name:add')")
    @Log(title = "公司名称", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody MystockName mystockName)
    {
        return toAjax(mystockNameService.insertMystockName(mystockName));
    }

    /**
     * 修改公司名称
     */
    @PreAuthorize("@ss.hasPermi('system:name:edit')")
    @Log(title = "公司名称", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody MystockName mystockName)
    {
        return toAjax(mystockNameService.updateMystockName(mystockName));
    }

    /**
     * 删除公司名称
     */
    @PreAuthorize("@ss.hasPermi('system:name:remove')")
    @Log(title = "公司名称", businessType = BusinessType.DELETE)
	@DeleteMapping("/{tsCodes}")
    public AjaxResult remove(@PathVariable String[] tsCodes)
    {
        return toAjax(mystockNameService.deleteMystockNameByTsCodes(tsCodes));
    }
}
